package img;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

/**
 * @author wzby
 * @Date: 2022/8/3 15:11
 */
public class Img3 {
    public static void main(String[] args) throws IOException {
        var img = new BufferedImage(300, 300, BufferedImage.TYPE_INT_ARGB);
        var g = img.createGraphics();
        //抗锯齿
        g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_GASP);
        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_DEFAULT);


        g.setColor(Color.BLACK);
        g.fillRect(0, 0, 600, 600);
        //fillRect矩形

        int x = 0;
        int y = 0;
        g.setColor(new Color(0, 0, 255));
        g.fillOval(x, y, 100, 100);
        //fillOval圆形
        g.setColor(Color.PINK);
        g.drawOval(100, 100, 100, 200);
        g.dispose();
        ImageIO.write(img, "png", new File("ch09/src/pho/img3.png"));
        Runtime.getRuntime().exec("cmd /k start ch09/src/pho/img3.png");
    }
}
